﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdApLongTransactionReactor : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdApLongTransactionReactor(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdApLongTransactionReactor_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdApLongTransactionReactor obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdApLongTransactionReactor()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdApLongTransactionReactor(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdApLongTransactionReactor() : this(TD_DbPINVOKE.new_OdApLongTransactionReactor(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdApLongTransactionReactor(this.swigCPtr.Handle, true));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdApLongTransactionReactor cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdApLongTransactionReactor_cast(OdRxObject.getCPtr(pObj));
			OdApLongTransactionReactor result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdApLongTransactionReactor_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdApLongTransactionReactor.swigMethodTypes1) ? TD_DbPINVOKE.OdApLongTransactionReactor_isASwigExplicitOdApLongTransactionReactor(this.swigCPtr) : TD_DbPINVOKE.OdApLongTransactionReactor_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdApLongTransactionReactor.swigMethodTypes0) ? TD_DbPINVOKE.OdApLongTransactionReactor_queryXSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : TD_DbPINVOKE.OdApLongTransactionReactor_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdApLongTransactionReactor createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdApLongTransactionReactor_createObject();
			OdApLongTransactionReactor result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdApLongTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void beginCheckOut(OdDbLongTransaction arg0, OdDbObjectIdArray originList)
		{
			if (this.SwigDerivedClassHasMethod("beginCheckOut", OdApLongTransactionReactor.swigMethodTypes2))
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_beginCheckOutSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0), OdDbObjectIdArray.getCPtr(originList));
			}
			else
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_beginCheckOut(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0), OdDbObjectIdArray.getCPtr(originList));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void endCheckOut(OdDbLongTransaction arg0)
		{
			if (this.SwigDerivedClassHasMethod("endCheckOut", OdApLongTransactionReactor.swigMethodTypes3))
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_endCheckOutSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			else
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_endCheckOut(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void beginCheckIn(OdDbLongTransaction arg0)
		{
			if (this.SwigDerivedClassHasMethod("beginCheckIn", OdApLongTransactionReactor.swigMethodTypes4))
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_beginCheckInSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			else
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_beginCheckIn(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void endCheckIn(OdDbLongTransaction arg0)
		{
			if (this.SwigDerivedClassHasMethod("endCheckIn", OdApLongTransactionReactor.swigMethodTypes5))
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_endCheckInSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			else
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_endCheckIn(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void abortLongTransaction(OdDbLongTransaction arg0)
		{
			if (this.SwigDerivedClassHasMethod("abortLongTransaction", OdApLongTransactionReactor.swigMethodTypes6))
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_abortLongTransactionSwigExplicitOdApLongTransactionReactor(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			else
			{
				TD_DbPINVOKE.OdApLongTransactionReactor_abortLongTransaction(this.swigCPtr, OdDbLongTransaction.getCPtr(arg0));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdApLongTransactionReactor.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdApLongTransactionReactor.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("beginCheckOut", OdApLongTransactionReactor.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_2(this.SwigDirectorbeginCheckOut);
			}
			if (this.SwigDerivedClassHasMethod("endCheckOut", OdApLongTransactionReactor.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_3(this.SwigDirectorendCheckOut);
			}
			if (this.SwigDerivedClassHasMethod("beginCheckIn", OdApLongTransactionReactor.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_4(this.SwigDirectorbeginCheckIn);
			}
			if (this.SwigDerivedClassHasMethod("endCheckIn", OdApLongTransactionReactor.swigMethodTypes5))
			{
				this.swigDelegate5 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_5(this.SwigDirectorendCheckIn);
			}
			if (this.SwigDerivedClassHasMethod("abortLongTransaction", OdApLongTransactionReactor.swigMethodTypes6))
			{
				this.swigDelegate6 = new OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_6(this.SwigDirectorabortLongTransaction);
			}
			TD_DbPINVOKE.OdApLongTransactionReactor_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4, this.swigDelegate5, this.swigDelegate6);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdApLongTransactionReactor));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private void SwigDirectorbeginCheckOut(IntPtr arg0, IntPtr originList)
		{
			this.beginCheckOut((OdDbLongTransaction)Teigha.Core.Helpers.odrxCreateObjectInternal(arg0, false), new OdDbObjectIdArray(originList, false));
		}

		private void SwigDirectorendCheckOut(IntPtr arg0)
		{
			this.endCheckOut((OdDbLongTransaction)Teigha.Core.Helpers.odrxCreateObjectInternal(arg0, false));
		}

		private void SwigDirectorbeginCheckIn(IntPtr arg0)
		{
			this.beginCheckIn((OdDbLongTransaction)Teigha.Core.Helpers.odrxCreateObjectInternal(arg0, false));
		}

		private void SwigDirectorendCheckIn(IntPtr arg0)
		{
			this.endCheckIn((OdDbLongTransaction)Teigha.Core.Helpers.odrxCreateObjectInternal(arg0, false));
		}

		private void SwigDirectorabortLongTransaction(IntPtr arg0)
		{
			this.abortLongTransaction((OdDbLongTransaction)Teigha.Core.Helpers.odrxCreateObjectInternal(arg0, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_0 swigDelegate0;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_1 swigDelegate1;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_2 swigDelegate2;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_3 swigDelegate3;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_4 swigDelegate4;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_5 swigDelegate5;

		private OdApLongTransactionReactor.SwigDelegateOdApLongTransactionReactor_6 swigDelegate6;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdDbLongTransaction),
			typeof(OdDbObjectIdArray)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdDbLongTransaction)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdDbLongTransaction)
		};

		private static Type[] swigMethodTypes5 = new Type[]
		{
			typeof(OdDbLongTransaction)
		};

		private static Type[] swigMethodTypes6 = new Type[]
		{
			typeof(OdDbLongTransaction)
		};

		public delegate IntPtr SwigDelegateOdApLongTransactionReactor_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdApLongTransactionReactor_1();

		public delegate void SwigDelegateOdApLongTransactionReactor_2(IntPtr arg0, IntPtr originList);

		public delegate void SwigDelegateOdApLongTransactionReactor_3(IntPtr arg0);

		public delegate void SwigDelegateOdApLongTransactionReactor_4(IntPtr arg0);

		public delegate void SwigDelegateOdApLongTransactionReactor_5(IntPtr arg0);

		public delegate void SwigDelegateOdApLongTransactionReactor_6(IntPtr arg0);
	}
}
